library(gplots)


# Selective sweeps

ress <- read.csv("sweeps.csv",header=FALSE)

selmulab <- c("10^-5","10^-6","10^-7","10^-8")

pdf("number.of.sweeps.pdf",width=6, height=6)

for(selmu in 1:4){

res <- ress[((selmu-1)*6+1):(selmu*6),]
colnames(res) <- c("r=0","r=0.25","r=0.5","r=0.75","r=1")
for(i in 1:1){
rownames(res) <- c("s=0.001","s=0.01","s=0.1","s=0.5","s=1","s=2")
}

res <- as.matrix(res)
mp <- barplot2(res/9, beside = TRUE,
        col = gray(1-(0:5/5)),
        ylim = c(0, 1.5),
        main = paste("Selective mutation rate = ", selmulab[selmu]), font.main = 4,
        plot.grid = TRUE)
#mtext(side = 1, at = colMeans(mp), line = 2, text = paste("Mean", formatC(colMeans(res))), col = "red")
legend(0,1.4,legend=rownames(res),fill=gray(1-(0:5/5)))
mtext(side=2, text="Average number of sweeps per run",line=2)
mtext(side=1, text="Crypt division probability (r) and selective coefficient (s)",line=2)

}

dev.off()


